import config from "@/config"
import http from "@/utils/request"

// 合同
export default {
  // 合同管理
  getContracts: {
    url: `${config.API_URL}/contract/list`,
    name: "获取合同列表",
    get: function (param) {
      return new Promise((resolve, reject) => {
        http.get(this.url, param).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },

  addContract: {
    url: `${config.API_URL}/contract/add`,
    name: "添加合同",
    post: function (data) {
      return new Promise((resolve, reject) => {
        http.post(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },

  updateContract: {
    url: `${config.API_URL}/contract/update`,
    name: "修改合同",
    post: function (data) {
      return new Promise((resolve, reject) => {
        http.post(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },

  deleteContract: {
    url: `${config.API_URL}/contract/delete`,
    name: "删除合同",
    post: function (data) {
      return new Promise((resolve, reject) => {
        http.postParam(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },

  submitCheck: {
    url: `${config.API_URL}/contract/commitAudit`,
    name: "提交合同审核",
    post: function (data) {
      return new Promise((resolve, reject) => {
        http.postParam(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },

  checkContract: {
    url: `${config.API_URL}/contract/audit`,
    name: "审核合同",
    post: function (data) {
      return new Promise((resolve, reject) => {
        http.postParam(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },

  getContractById: {
    url: `${config.API_URL}/contract/contractById`,
    name: "跟进id获取合同详情",
    post: function (data) {
      return new Promise((resolve, reject) => {
        http.postParam(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },

  getContractProgress: {
    url: `${config.API_URL}/contract/progress`,
    name: "获取合同进度",
    get: function (data) {
      return new Promise((resolve, reject) => {
        http.get(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },

  addSupplement: {
    url: `${config.API_URL}/contract/supplement`,
    name: "添加合同补充",
    post: function (data) {
      return new Promise((resolve, reject) => {
        http.post(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },

  // 获取编号
  getNum: {
    url: `${config.API_URL}/contract/getNum`,
    name: "获取编号",
    post: function (data = {}) {
      return new Promise((resolve, reject) => {
        http.post(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },

  getContractCountData: {
    url: `${config.API_URL}/contract/statistics`,
    name: "获取合同统计数据",
    get: function (data = {}) {
      return new Promise((resolve, reject) => {
        http.get(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },


  // 报价管理
  quoteManagement: {
    getQuotes: {
      url: `${config.API_URL}/quote/list`,
      name: "获取报价列表",
      get: function (data) {
        return new Promise((resolve, reject) => {
          http.get(this.url, data).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },

    getStatusQuotes: {
      url: `${config.API_URL}/quote/auditList`,
      name: "获取已审核报价列表",
      get: function (data) {
        return new Promise((resolve, reject) => {
          http.get(this.url, data).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },

    addQuote: {
      url: `${config.API_URL}/quote/add`,
      name: "添加报价",
      post: function (data) {
        return new Promise((resolve, reject) => {
          http.post(this.url, data).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },

    updateQuote: {
      url: `${config.API_URL}/quote/update`,
      name: "修改报价",
      post: function (data) {
        return new Promise((resolve, reject) => {
          http.post(this.url, data).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },

    deleteQuote: {
      url: `${config.API_URL}/quote/delete`,
      name: "删除报价",
      post: function (data) {
        return new Promise((resolve, reject) => {
          http.postParam(this.url, data).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },

    getQuoteDetailById: {
      url: `${config.API_URL}/quote/listById`,
      name: "跟进id获取报价详情",
      post: function (data) {
        return new Promise((resolve, reject) => {
          http.postParam(this.url, data).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },
    submitCheck: {
      url: `${config.API_URL}/quote/commitAudit`,
      name: "提交报价审核",
      post: function (data) {
        return new Promise((resolve, reject) => {
          http.postParam(this.url, data).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },

    checkQuote: {
      url: `${config.API_URL}/quote/audit`,
      name: "审核报价",
      post: function (data) {
        return new Promise((resolve, reject) => {
          http.postParam(this.url, data).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    }
  },

  // 根据客户id获取合同列表
  getContractByCustomerId: {
    url: `${config.API_URL}/customer/listById`,
    name: "根据客户id获取合同列表",
    get: function (param) {
      return new Promise((resolve, reject) => {
        http.get(this.url, param).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },


  // 跟进记录管理
  followRecord: {
    getFollowRecords: {
      url: `${config.API_URL}/follow/followList`,
      name: "获取跟进记录",
      get: function (param) {
        return new Promise((resolve, reject) => {
          http.get(this.url, param).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },

    addFollowRecord: {
      url: `${config.API_URL}/follow/add`,
      name: "添加跟进记录",
      post: function (data) {
        return new Promise((resolve, reject) => {
          http.post(this.url, data).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },

    updateFollowRecord: {
      url: `${config.API_URL}/follow/update`,
      name: "修改跟进记录",
      post: function (data) {
        return new Promise((resolve, reject) => {
          http.post(this.url, data).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },

    deleteFollowRecord: {
      url: `${config.API_URL}/follow/delete`,
      name: "删除跟进记录",
      post: function (data) {
        return new Promise((resolve, reject) => {
          http.postParam(this.url, data).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },

    getDetailById: {
      url: `${config.API_URL}/follow/listById`,
      name: "跟进id获取跟进记录详情",
      post: function (data) {
        return new Promise((resolve, reject) => {
          http.postParam(this.url, data).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },

    submitCheck: {
      url: `${config.API_URL}/follow/commitAudit`,
      name: "提交审核跟进记录",
      post: function (data) {
        return new Promise((resolve, reject) => {
          http.postParam(this.url, data).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },

    checkFollowRecord: {
      url: `${config.API_URL}/follow/audit`,
      name: "审核跟进记录",
      post: function (data) {
        return new Promise((resolve, reject) => {
          http.postParam(this.url, data).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },
  },

  // 评论
  comment: {
    getCommentsById: {
      url: `${config.API_URL}/comment/commentList`,
      name: "跟进id获取评论",
      get: function (param) {
        return new Promise((resolve, reject) => {
          http.get(this.url, param).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },

    addComment: {
      url: `${config.API_URL}/comment/add`,
      name: "添加评论",
      post: function (data) {
        return new Promise((resolve, reject) => {
          http.post(this.url, data).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },

    deleteComment: {
      url: `${config.API_URL}/comment/delete`,
      name: "删除评论",
      post: function (data) {
        return new Promise((resolve, reject) => {
          http.postParam(this.url, data).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },

    replyComment: {
      url: `${config.API_URL}/comment/reply`,
      name: "回复评论",
      post: function (data) {
        return new Promise((resolve, reject) => {
          http.post(this.url, data).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    }

  },

  // 合同条款
  contractClause: {
    getClauseList: {
      url: `${config.API_URL}/contractArticle/list`,
      name: "获取合同条款列表",
      get: function () {
        return new Promise((resolve, reject) => {
          http.get(this.url).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },

    getClauseById: {
      url: `${config.API_URL}/contractArticle/oneDetail`,
      name: "根据获取合同条款",
      post: function (data) {
        return new Promise((resolve, reject) => {
          http.postParam(this.url, data).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },

    addClause: {
      url: `${config.API_URL}/contractArticle/add`,
      name: "添加合同条款",
      post: function (data) {
        return new Promise((resolve, reject) => {
          http.post(this.url, data).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },

    updateClause: {
      url: `${config.API_URL}/contractArticle/update`,
      name: "修改合同条款",
      post: function (data) {
        return new Promise((resolve, reject) => {
          http.post(this.url, data).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },

    deleteClause: {
      url: `${config.API_URL}/contractArticle/delete`,
      name: "删除合同条款",
      post: function (data) {
        return new Promise((resolve, reject) => {
          http.postParam(this.url, data).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },

    setDefaultClause: {
      url: `${config.API_URL}/contractArticle/setUpDefault`,
      name: "设置默认合同条款",
      post: function (data) {
        return new Promise((resolve, reject) => {
          http.postParam(this.url, data).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },

    getDefaultClause: {
      url: `${config.API_URL}/contractArticle/defaultArticle`,
      name: "获取默认合同条款",
      get: function (data) {
        return new Promise((resolve, reject) => {
          http.get(this.url, data).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    }

  },


  // 合同配置
  contractConfig: {
    getConfigDetail: {
      url: `${config.API_URL}/contractFit/detail`,
      name: "获取配置详情",
      post: function (data) {
        return new Promise((resolve, reject) => {
          http.postParam(this.url, data).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },

    updateConfig: {
      url: `${config.API_URL}/contractFit/update`,
      name: "修改合同配置",
      post: function (data) {
        return new Promise((resolve, reject) => {
          http.post(this.url, data).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },
  },

  detailList: {
    getContract: {
      url: `${config.API_URL}/contract/contractAllInformation`,
      name: "获取合同详情",
      get: function (data) {
        return new Promise((resolve, reject) => {
          http.get(this.url, data).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },
    getCustomerDetail: {
      url: `${config.API_URL}/customer/informationOfCustomer`,
      name: "获取客户详情",
      get: function (data) {
        return new Promise((resolve, reject) => {
          http.get(this.url, data).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },
    getProduceOrder: {
      url: `${config.API_URL}/produce/informationOfProduce`,
      name: "获取生产详情",
      get: function (data) {
        return new Promise((resolve, reject) => {
          http.get(this.url, data).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },
    getDeliverDetail: {
      url: `${config.API_URL}/deliver/informationOfDeliver`,
      name: "获取送货详情",
      get: function (data) {
        return new Promise((resolve, reject) => {
          http.get(this.url, data).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },
  },
  // 合同变更
  contractChange: {
    addContractChange: {
      url: `${config.API_URL}/contractChange/add`,
      name: "添加合同变更",
      post: function (data) {
        return new Promise((resolve, reject) => {
          http.post(this.url, data).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },
    getContractChange: {
      url: `${config.API_URL}/contractChange/list`,
      name: "获取合同变更列表",
      get: function (data) {
        return new Promise((resolve, reject) => {
          http.get(this.url, data).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },
    getContractChangeDetail: {
      url: `${config.API_URL}/contractChange/detail`,
      name: "获取合同变更详情",
      get: function (data) {
        return new Promise((resolve, reject) => {
          http.get(this.url, data).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },
  },
  // 外发
  productionOut: {
    getProductionOutList: {
      url: `${config.API_URL}/contractSchedulingOut/list`,
      name: "获取外发列表",
      get: function (data) {
        return new Promise((resolve, reject) => {
          http.get(this.url, data).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },
    addProductionOut: {
      url: `${config.API_URL}/contractSchedulingOut/add`,
      name: "添加外发",
      post: function (data) {
        return new Promise((resolve, reject) => {
          http.post(this.url, data).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },
    confirmProductionOut: {
      url: `${config.API_URL}/contractSchedulingOut/finished`,
      name: "确认完成外发",
      post: function (data) {
        return new Promise((resolve, reject) => {
          http.postParam(this.url, data).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },
  },

  // 成交管理
  dealManagement: {
    getDealList: {
      url: `${config.API_URL}/customer/turnoverList`,
      name: "获取成交客户列表",
      get: function (data) {
        return new Promise((resolve, reject) => {
          http.get(this.url, data).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },
    getContractList: {
      url: `${config.API_URL}/customer/contractList`,
      name: "获取成交客户合同",
      get: function (data) {
        return new Promise((resolve, reject) => {
          http.get(this.url, data).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },
    getQuoteList: {
      url: `${config.API_URL}/customer/quoteList`,
      name: "获取成交客户报价",
      get: function (data) {
        return new Promise((resolve, reject) => {
          http.get(this.url, data).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },
  }

}
